import axios from 'axios'
import { ICommon } from './common'
declare let Common: ICommon

const service = axios.create({
  timeout: 60000,
  baseURL: Common.getLocalConfig().server
})

// Request interceptors
service.interceptors.request.use(
  (config) => {
    return config
  },
  (error) => {
    Promise.reject(error)
  }
)

// Response interceptors
service.interceptors.response.use(
  (response) => {
    if (response.status === 200) {
      return response
    }
    return Promise.reject(response)
  },
  (error) => {
    return Promise.reject(error)
  }
)

export default service
